package com.itheima_02;

import java.lang.reflect.Field;

public class Test03 {
    public static void main(String[] args) throws Exception {
        Class aClass = Class.forName("com.itheima_02.Student");
        Object o = aClass.newInstance();
        Field field = aClass.getField("name");
        String o1 = (String) field.get(o);
        System.out.println(o1);
        System.out.println("----------------------------------");
        Class aClass1 = Class.forName("com.itheima_02.Student");
        Object o2 = aClass1.newInstance();
        Field field1 = aClass.getField("name");
        field1.set(o2,"zhangsan");
        String o3 = (String) field1.get(o2);
        System.out.println(o3);
        System.out.println("--------------------------------------");
        Class aClass2 = Class.forName("com.itheima_02.Student");
        Object o4 = aClass2.newInstance();
        Field field2 = aClass2.getDeclaredField("money");
        field2.setAccessible(true);
        Object o5 = field2.get(o4);
        System.out.println(o5);

    }
}
